package com.e3.web.core.client;

import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.Viewport;
import com.extjs.gxt.ui.client.widget.layout.FitLayout;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.user.client.ui.RootPanel;

public abstract class SuperEntryPoint implements EntryPoint {

	public void onModuleLoad() {
		ResourceRPCService.Util.getInstance().getClientSession(!GWT.isScript(),new AsyncCallback<GxtClientSession>() {
			public void onFailure(Throwable caught) {
				
			}

			public void onSuccess(GxtClientSession result) {
				GXTHelper.setClientSession(result);
				drawUI();
			}
		});
	}

	protected void drawUI() {
		Viewport view = new Viewport();
		FitLayout fl = new FitLayout();
		view.setLayout(fl);
		
		LayoutContainer container = getUIComponent();
		view.add(container);

		RootPanel rootPanel = RootPanel.get();
		rootPanel.add(view);
	}

	protected abstract LayoutContainer getUIComponent(); 
}
